package com.yun.newBlog.blog.controller;

import com.qiniu.util.Auth;
import com.yun.newBlog.blog.vo.CommonResponseVo;
import com.yun.newBlog.blog.vo.UploadTokenVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import tk.mybatis.spring.annotation.MapperScan;

import javax.servlet.http.HttpServletRequest;

@MapperScan("com.yun")
@RestController
@CrossOrigin
@RequestMapping("/upload")
@Slf4j
public class UploadController {

    private String accessKey = "Vg-2E_yQXJF0u_1Q7s0UCFE_kyT__cbr38B694M0";

    private String secretKey = "vt4AEhBvFfaTRlHlqkGOxA8jO1Xf2ZipxS5FZTIX";

    private String bucket = "plugins";

    @RequestMapping("/token/get")
    public UploadTokenVO getToken() {
        Auth auth = Auth.create(accessKey,secretKey);
        String upToken = auth.uploadToken(bucket);

        UploadTokenVO uploadTokenVO = new UploadTokenVO();
        uploadTokenVO.setToken(upToken);
        return uploadTokenVO;
    }
}
